<template>
  <div>
    <!-- 带类型声明 -->
    <button @click.once="triggerEvent">Trigger Custom Even</button>
    <button @click="triggerSubmit">Trigger Submit</button>
  </div>
</template>

<script lang="ts" setup>
//带类型的声明
const emit = defineEmits<{
  (e: 'customEvent', message: string): void;
  (e: 'submit', payload: { email: string; passworld: string }): void;

}>();

// 触发 customEvent 事件
const triggerEvent = () => {
  emit('customEvent', 'hello world');
};
// 触发 submit 事件
const triggerSubmit = () => {
  const result = { email: 'user@example.com', passworld: 'password123' };
  emit('submit', result);
};
</script>
